package org.example;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;

    public class Main {

        public static void main(String[] args){
            Phone phone1 = new Phone();
            Phone phone2 = new Phone();

            new Thread(() -> {
                try {
                    Phone.sendSms();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            },"A").start();

            new Thread(phone2::call,"B").start();


        }
    }
    class Phone{
        public static synchronized void sendSms() throws InterruptedException {
            TimeUnit.SECONDS.sleep(5);
            System.out.println("发短信");
        }
        public synchronized void call(){
            System.out.println("打电话");
        }

    }
